﻿using System;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using LFloatMath.Math;

namespace IQIGame.Onigao.Logic
{
    public class Skilleffective_ExtraTurn : SkillEffective
    {
        protected override ISerializeCustomPOD OnExecute(SkillEffectiveData data, Unit target, SkillEffectiveContext context, int effectiveIndex, out SkillEffectiveResponse startResp)
        {
            startResp = null;
            if (data.effectiveConfig.customConfig is SkillEffective_ExtraTurn_ConfigData rConfig)
            {
                var rQueueCtrl = target.battle.playCtrl.queueCtrl;
                if (rConfig.remove)
                {
                    rQueueCtrl.RemoveExtraTurn(target, rConfig.count);
                }
                else
                {
                    rQueueCtrl.AddExtraTurn(target, rConfig.count);
                }
            }

            return null;
        }

#if UNITY_EDITOR
        public override string ToString(SkillCustomConfig config)
        {
            var rConfig = config as SkillEffective_ExtraTurn_ConfigData;
            return $"{(rConfig.remove ? "移除" : "增加")}{rConfig.count}额外回合";
        }
#endif
    }
}